<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="./plugin/layui/css/layui.css"/>
    <script src="plugin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
</head>
    <script>
        /*修改视频  李英勇*/



        layui.use(['jquery', 'layer', 'form'], function () {
            let $ = layui.jquery, layer = layui.layer, form = layui.form;

            let vid = localStorage.getItem("vid");
            let refreshToken = localStorage.getItem("refreshToken");
            let token = localStorage.getItem("token");
            $.ajax({
                url: "getVideoByVid/" + vid,
                type: "get",
                headers: {"refreshToken": refreshToken,"token":token},
                success: function (res,status,xhr) {
                    if (res.code == 0) {
                        $("#knowledge").val(res.data.knowledge);
                        $("#content").val(res.data.content);
                        if (xhr.getResponseHeader("token")!=null) {
                            //更新本地token
                            localStorage.setItem("token", res.headers.token);
                        }
                    } else {
                        layer.msg(res.msg);
                    }
                }
            });

            $("#commit").on("click",function(e){
                e.preventDefault();
                var knowledge=$("#knowledge").val();
                var content=$("#content").val();
                var data={
                    "knowledge":knowledge,
                    "content":content,
                    "vid":vid
                }
                $.ajax({
                    url:"updateVideo",
                    data:data,
                    type:"post",
                    headers: {"refreshToken": refreshToken,"token":token},
                    success:function(res,status,xhr){
                        if(res.code==0){
                            layer.msg(res.msg);
                            if (xhr.getResponseHeader("token")!=null) {
                                //更新本地token
                                localStorage.setItem("token", res.headers.token);
                            }
                        }
                    }
                });
            });

        });
    </script>
<body>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">知识点</label>
            <div class="layui-input-block">
                <input type="text" name="knowledge" id="knowledge" required  lay-verify="required" placeholder="请输入内容" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="content" id="content" placeholder="请输入内容" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo" id="commit">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
</body>
</html>